<template>
  <div>
    <div class="carousel">
      <el-carousel
        :interval="5000"
        height="142px"
        arrow="always"
      >
        <el-carousel-item>
          <img
            src="../static/longSwiper.png"
            style="height:100%;width:100%;object-fit:cover"
          >
        </el-carousel-item>
        <el-carousel-item>
          <img
            src="../static/longSwiper.png"
            style="height:100%;width:100%;object-fit:cover"
          >
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="region">
      <div class="title">
        <div class="text">肉桂资讯</div>
        <div
          class="right"
          @click="goPage('/information')"
        >更多>></div>
      </div>
      <div style="clear:both;" />
      <div class="dataList">
        <div
          v-for="article in informationList"
          :key="article.id"
          class="data"
          @click="goDetail(article.id)"
        >
          <img :src="article.coverImg">
          <div class="data-title">
            {{ article.title }}
          </div>
          <div class="des">
            {{ article.summary }}
          </div>
          <div class="go">查看详情>></div>
        </div>
      </div>
    </div>
    <div class="region">
      <div class="title">
        <div class="text">肉桂行情</div>
        <div
          class="right"
          @click="goPage('/bigdata-market')"
        >更多>></div>
      </div>
      <div style="clear:both;" />
      <div />
      <div class="market-region">
        <div class="market-article">
          <div class="article-list">
            <div
              v-for="item in marketArticleList"
              :key="item.id"
              class="article"
              @click="goDetail(item.id)"
            >
              <div class="article-info">
                <div class="article-title">{{ item.title }}</div>
                <div class="article-time">{{ item.startTime }}</div>
                <div style="clear:both" />
              </div>
              <div class="article-summary">{{ item.summary }}</div>

            </div>
          </div>
        </div>
        <div class="marketPrice">
          <marketPriceTrend />
        </div>
      </div>
    </div>
    <div class="region">
      <div class="title">
        <div class="text">肉桂舆情</div>
        <div
          class="right"
          @click="goPage('/publicOption')"
        >更多>></div>
      </div>
      <div style="clear:both;" />
      <div class="public-region">
        <div class="dataList">
          <div
            v-for="article in publicOptionList"
            :key="article.id"
            class="data"
            @click="goDetail(article.id)"
          >
            <img :src="article.coverImg">
            <div class="data-title">
              {{ article.title }}
            </div>
            <div class="des">
              {{ article.summary }}
            </div>
            <div class="go">查看详情>></div>
          </div>
        </div>
        <wordCloud class="wordCloud" />
      </div>

    </div>
  </div>
</template>

<script>
import marketPriceTrend from '../market/components/marketPriceTrend.vue'
import wordCloud from './components/wordCloud.vue'
import { getArticlePage } from '@/api/article/article'
export default {
  components: { marketPriceTrend, wordCloud },
  data() {
    return {
      chartList: [
        {
          img: 'https://gulimall-void.oss-cn-guangzhou.aliyuncs.com/2024-03-16/d714c90f-5abf-4b4f-8351-d9f4563827a8_%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202024-03-16%20073112.png',
          title: '肉桂云图一',
          des: '肉桂产销数据云图',
          path: '/chart1'
        },
        {
          img: 'https://gulimall-void.oss-cn-guangzhou.aliyuncs.com/2024-02-28/f763715d-0ef9-4ea1-8fb7-e504566f9b59_20200923135150_103654.jpg',
          title: '肉桂云图二',
          des: '肉桂产销数据云图',
          path: '/chart2'
        },
        {
          img: 'https://gulimall-void.oss-cn-guangzhou.aliyuncs.com/2024-03-16/d714c90f-5abf-4b4f-8351-d9f4563827a8_%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202024-03-16%20073112.png',
          title: '肉桂云图一',
          des: '肉桂产销数据云图',
          path: '/chart1'
        },
        {
          img: 'https://gulimall-void.oss-cn-guangzhou.aliyuncs.com/2024-03-16/d714c90f-5abf-4b4f-8351-d9f4563827a8_%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202024-03-16%20073112.png',
          title: '肉桂云图一',
          des: '肉桂产销数据云图',
          path: '/chart1'
        }
      ],
      informationList: [],
      publicOptionList: [],
      marketArticleList: []
    }
  },
  mounted() {
    this.load()
  },
  methods: {
    async load() {
      const informationData = await getArticlePage({
        pageNum: 1,
        pageSize: 4,
        categoryId: 1
      })
      this.informationList = informationData.data.records

      const marketData = await getArticlePage({
        pageNum: 1,
        pageSize: 4,
        categoryId: 4
      })
      this.marketArticleList = marketData.data.records

      const publicOpinionData = await getArticlePage({
        pageNum: 1,
        pageSize: 4,
        categoryId: 5
      })
      this.publicOptionList = publicOpinionData.data.records
    },
    goPage(path) {
      this.$router.push(path)
    },
    goDetail(id) {
      this.$router.push(`/bigdata-articleDetail?id=${id}`)
    }
  }
}
</script>

<style lang="scss" scoped>
.carousel {
  margin-top: 10px;
  height: 142px;
  width: 100vw;
  margin-bottom: 30px;
}

.region {
  width: 87%;
  margin: 30px auto;

  .title {
    height: 70px;
    .text {
      font-size: 30px;
      font-weight: 600;
      float: left;
    }
    .right {
      float: right;
      color: #666666;
      cursor: pointer;
    }

    .right:hover {
      color: rgb(133, 194, 38);
    }
  }
  .dataList {
    display: flex;
    .data {
      background-color: #eeeeee;
      width: 25%;
      margin-right: 1.3%;
      cursor: pointer;
      img {
        height: 60%;
        width: 100%;
        object-fit: cover;
      }
      .data-title {
        margin: 10px;
        font-size: 16px;
        font-weight: 600;
        word-break: break-all;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
      }
      .des {
        height: 35px;
        font-size: 15px;
        word-break: break-all;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        margin: 10px;
        color: #666666;
      }
      .go {
        border: 1px solid rgb(133, 194, 38);
        color: rgb(133, 194, 38);
        border-radius: 10px;
        width: 100px;
        text-align: center;
        padding: 2px;
        margin: 20px 10px;
      }

      .go:hover {
        background: rgb(133, 194, 38);
        color: white;
      }
    }
    .data:nth-child(4) {
      margin-right: 0px;
    }
    .data:hover {
      transform: translateY(-10px);
      box-shadow: 2px 8px 6px rgba(0, 0, 0, 0.1);
      transition-duration: 500ms;
    }
  }
}

.market-region {
  display: flex;

  .market-article {
    width: 49%;
    margin: 0.5%;
    height: 500px;
    padding-top: 20px;
    padding-right: 50px;

    .article {
      border-bottom: 1px solid #999;
      height: 120px;
      cursor: pointer;

      .article-title {
        font-size: 17px;
        font-weight: 600;
        max-width: 70%;
        word-break: break-all;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        margin: 10px;
        float: left;
      }

      .article-time {
        margin-top: 10px;
        color: #666;
        text-align: right;
        float: right;
        font-size: 14px;
      }

      .article-summary {
        font-size: 15px;
        line-height: 30px;
        word-break: break-all;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        margin: 10px;
        color: #666666;
      }
    }
  }
}

.marketPrice {
  width: 49%;
  margin: 0.5%;
  height: 500px;
  padding-top: 20px;
  padding-right: 50px;
}

.public-region {
  width: 100%;
  display: flex;

  .dataList {
    display: flex;
    width: 50%;
    .data {
      background-color: #eeeeee;
      width: 50%;
      margin-right: 1.3%;
      cursor: pointer;
      img {
        height: 60%;
        width: 100%;
        object-fit: cover;
      }
      .data-title {
        margin: 10px;
        font-size: 16px;
        font-weight: 600;
        word-break: break-all;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
      }
      .des {
        height: 35px;
        font-size: 15px;
        word-break: break-all;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        margin: 10px;
        color: #666666;
      }
      .go {
        border: 1px solid rgb(133, 194, 38);
        color: rgb(133, 194, 38);
        border-radius: 10px;
        width: 100px;
        text-align: center;
        padding: 2px;
        margin: 20px 10px;
      }

      .go:hover {
        background: rgb(133, 194, 38);
        color: white;
      }
    }
    .data:nth-child(4) {
      margin-right: 0px;
    }
    .data:hover {
      transform: translateY(-10px);
      box-shadow: 2px 8px 6px rgba(0, 0, 0, 0.1);
      transition-duration: 500ms;
    }
  }

  .wordCloud {
    width: 48%;
    height: 400px;
  }
}
</style>
